package com.wisemoresystem.seal.action_app.compare;

import java.io.File;
import java.io.IOException;
import java.util.Map;

import org.ne.framework.data.util.ChkTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wisemoresystem.seal.action_rest.BMPLoader;
import com.wisemoresystem.seal.base.action.ProjBaseAction;
import com.wisemoresystem.seal.config.Config;
import com.wisemoresystem.seal.model.t_file;
import com.wisemoresystem.seal.service.SealSetService;
import com.wisemoresystem.seal.util.json.JsonTools;

@Controller("ixCompare")
@Scope("prototype")
@RequestMapping("/ix/compare")
public class CompareAction extends ProjBaseAction {

	@Autowired
	private SealSetService sService;
	/**
	 * 印章验印
	 * @param json
	 * @return
	 */
	@RequestMapping("/seal")
	@ResponseBody
	public String list(String json) throws IOException {
		Map<String,Object> map = JsonTools.jsonStrToMap(json);
		
		String result = "";
		String oldPath = sService.getPath(map.get("file_id").toString());
		String newPath = sService.getPath(sService.file_id((String) map.get("file")));
		
		System.out.println(oldPath+"-------"+newPath);
		
		if(ChkTools.isNotNull(oldPath)&&ChkTools.isNotNull(newPath)){
			result =BMPLoader.compareImage(oldPath, newPath);
		}
		
		return JsonTools.toJson(result);
	}

}
